<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('云台设置参数')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                是否启动<select name="flag" th:with="type=${@dict.getType('sys_normal_disable')}">
                                <option value="3">无</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                            <li class="select-time">
                                <label>创建时间： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间：" name="beginTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间：" name="endTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;查询</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:setting:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:setting:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:setting:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:setting:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />

    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:setting:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:setting:remove')}]];
        var prefix = ctx + "system/setting";
        console.log("prefix=="+prefix);
        console.log("editFlag=="+editFlag);
        console.log("removeFlag=="+removeFlag);
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "云台参数设置",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '序号'
                    },
                    {
                        field: 'startAngle',
                        title: '起始角度'
                        // sortable: true
                    },
                    {
                        field: 'endAngle',
                        title: '终止角度'
                    },
                    {
                        field: 'speed',
                        title: '旋转速度'
                    },
                    {
                        field: 'hCoordinateCount',
                        title: '高度设置'
                        // visible: false
                    },
                    {
                        visible: editFlag == 'hidden' ? false : true,
                        title: '数据是否应用',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return statusTools(row);
                        }
                    },
                    {
                        field: 'createTime',
                        title: '创建时间',
                        sortable: true
                    },
                    {
                        field:'createBy',
                        title:'创建人'
                    },
                    {
                        field:'updateTime',
                        title:'修改时间',
                        sortable: true
                    },
                    {
                        field:'updateBy',
                        title:'修改人'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');

                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        });

        /* 鐢ㄦ埛鐘舵�佹樉绀� */
        function statusTools(row) {
            if (row.flag == 1) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
            }
        }

        /* 鍙傛暟璁剧疆-鍋滅敤 */
        function disable(id) {
            console.log("id=="+id);
            $.modal.confirm("纭瑕佸仠鐢ㄨ鏉℃暟鎹悧锛�", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "flag": 1 });
            })
        }

        /* 鍙傛暟璁剧疆-鍚敤 */
        function enable(id) {
            $.modal.confirm("纭瑕佸惎鐢ㄨ鏉℃暟鎹悧锛�", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "flag": 0 });
            })
        }
    </script>
</body>
</html>